//
//  MBProgressHUDManager.m
//  LYKitDemo
//
//  Created by Mac-Mini-KingVision on 16/1/22.
//  Copyright © 2016年 LiuWenYang. All rights reserved.
//

#import "LYProgressHUDManager.h"
#import <ReactiveCocoa.h>
#import "GiFHUD.h"
#define TipsDuration 1

@interface LYProgressHUDManager ()

@property (nonatomic, copy) NSMutableArray *gifImages;

@property (nonatomic, copy) MBProgressHUD *hud;

@end

@implementation LYProgressHUDManager

+(instancetype)shareInstance
{
    static LYProgressHUDManager *manager = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        
        manager = [[LYProgressHUDManager alloc] init];
        
    });
    return manager;
}

+(void)showTipsWithOnlyText:(NSString *)text inView:(UIView *)inView
{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:inView animated:YES];
    
    // Configure for text only and offset down
    hud.mode = MBProgressHUDModeText;
    hud.opacity = 0.5;
    hud.labelFont = [UIFont boldSystemFontOfSize:15.0];
    hud.labelText = text;
    hud.removeFromSuperViewOnHide = YES;
    [hud hide:YES afterDelay:TipsDuration];
}

+(void)showTipsInWindowWithOnlyText:(NSString *)text
{
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [self showTipsWithOnlyText:text inView:window];
}

+(void)showHUDInView:(UIView *)view withOverlayer:(BOOL)withOverlayer
{
    if (withOverlayer) {
        [GiFHUD showWithOverlayInView:view];
    }else{
        [GiFHUD show];
    }
    
}

+(void)hideHUD
{
    [GiFHUD dismiss];
}

+(void)configureImages:(NSMutableArray *)images
{
    [GiFHUD setGifWithImages:images];
//    [MMProgressHUD setPresentationStyle:MMProgressHUDPresentationStyleFade];
//    [MMProgressHUD setSpinAnimationImages:images];
//    [[MMProgressHUD sharedHUD] setOverlayMode:MMProgressHUDWindowOverlayModeLinear];
//    [MMProgressHUD sharedHUD].hud.imageView.mj_size = CGSizeMake(50, 50);
//    [[MMProgressHUD sharedHUD].hud updateLayoutFrames];
    
//    MBProgressHUD *hud = [[self shareInstance] hud];
//    if ([[self shareInstance] hud] == nil) {
////        MBProgressHUD *hud2 = [[MBProgressHUD alloc] init];
//        [[self shareInstance] setHud:[[MBProgressHUD alloc] init]];
//
//    }
//    UIImage *firstImage = [[MBProgressHUDManager shareInstance].gifImages firstObject];
//    hud.GifImageView = [[UIImageView alloc] initWithImage:firstImage];
//    hud.GifImageView.animationImages = images;
//    [[MBProgressHUDManager shareInstance] setGifImages:images];
}



@end
